Computer programs are groups of instructions that describe actions to be performed by a computer or other processor-based device. When a computer program is loaded and executed on computer hardware, the computer will behave in a predetermined manner by following the instructions of the computer program. Accordingly, the computer becomes a specialized machine that performs tasks prescribed by the instructions.
A programmer using one or more programming languages creates the instructions comprising a computer program. Typically, source code is specified or edited by a programmer manually and/or with help of an integrated development environment (IDE). Subsequently, the source code can be compiled or otherwise transformed by another program into computer instructions executable by a computer or like device.
Compilers and/or interpreters are language translators that translate a high-level program code and to low-level machine code to facilitate programming. Compilers separate program translation from execution. Generally, compilers have two main segments, namely one to generate an internal program representation and another to generated code from the representation. The generated code is subsequently executable by a target machine or platform. Conversely, interpreters are tightly tied with execution. More specifically, interpreters translate source code for execution by a cross-platform virtual machine. A hybrid approach also exists wherein source code is compiled to intermediate language code that can be interpreted for virtual machine execution.
Compilers and/or interpreters can provide a variety of programmatic aid beyond code translation. In one instance, such aid can center on a language type system. A type system defines program behavior by how expressions, values and the like are classified into types and the interaction between types. Accordingly, type systems vary across programming languages. The compiler and/or interpreter can utilize the type system to perform many useful tasks including type checking and type inference, among other things. Type checking can identify programmatic errors as a function of types associated with data, for example statically or dynamically. This can provide a degree of program safety by detecting meaningless or likely invalid code. Type inference, conventionally applied by functional programming languages, automatically infers types thereby making programming tasks easier by allowing programmers to omit explicit type annotations while still maintaining type safety.